package com.r2coding.music.api;

import com.r2coding.common.util.Result;
import com.r2coding.music.entity.TypeEntity;
import com.r2coding.music.service.TypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author:98k灬
 * @since:2022/05/22 19:56
 **/
@RestController
@RequestMapping("/api/type")
public class ApiTypeController {
    @Autowired
    TypeService typeService;

    /**
     * 查询类型列表
     *
     * @return 统一响应体
     */
    @GetMapping("/list")
    public Result list() {
        List<TypeEntity> list = typeService.list();
        return Result.ok(list);
    }

    /**
     * 查询类型详情
     *
     * @param id 类型id
     * @return 统一响应体
     */
    @GetMapping("/info/{id}")
    public Result info(@PathVariable("id") Integer id) {
        TypeEntity type = typeService.getById(id);
        return Result.ok(type);
    }
}
